Reorg introduce api package containing Entry interface#401
Reorg introduce api package containing Entry interface#401
Conversation
08c3843 to
651c414
Compare
faebr
left a comment
There was a problem hiding this comment.
I really like the interface separation from the stateless ops. I always struggled to fully understand sharedEntryAttributes and this breaks it down! I assume the commented out functions in entry.go are the ones you will still implement right?
There was a problem hiding this comment.
should the leaf_variants also be parts of the api / interface package or would it make sense to take this implementation into another package so to only have the interface definitions in the api package?
There was a problem hiding this comment.
possible... lets add an issue to investigate that. Nothing I would want to also squeeze into this PR.
| github.com/sdcio/logger v0.0.3 | ||
| github.com/sdcio/schema-server v0.0.34 | ||
| github.com/sdcio/sdc-protos v0.0.50 | ||
| github.com/sdcio/sdc-protos v0.0.51-0.20260304120533-f0e62d96331e |
There was a problem hiding this comment.
I guess sdc-protos should be tagged and this updated before this PR is merged
| explicitDeletes *sdcpb.PathSet | ||
| previouslyApplied bool | ||
| // revertPaths paths that are meant to be reverted. This is used for non-revertive intents. | ||
| revertPaths []*sdcpb.Path |
There was a problem hiding this comment.
We should probably discuss if we want a slice of pointers - imo we should avoid it where possible but that probably is a bigger job to refactor
There was a problem hiding this comment.
maybe open an issue for this
| } | ||
|
|
||
| deviationTree.GetDeviations(ctx, deviationChan) | ||
| dpc := ops.NewGetDeviationConfig(deviationChan) |
There was a problem hiding this comment.
I think that if we are creating a config to be passed to a processor we should use the config struct directly as it is self documenting, and follows go more closely
| } | ||
| // apply delete marker, setting owner delete flag on running intent | ||
| err = tree.NewOwnerDeleteMarker(tree.NewOwnerDeleteMarkerTaskConfig(tree.RunningIntentName, false)).Run(deleteRoot, d.taskPool) | ||
| err = processors.NewOwnerDeleteMarker(processors.NewOwnerDeleteMarkerTaskConfig(consts.RunningIntentName, false)).Run(deleteRoot, d.taskPool) |
There was a problem hiding this comment.
same as previous - here it makes it hard to know what false means, but using the struct directly would give some documentation
pkg/tree/ops/getdeletes.go
Outdated
| ) | ||
|
|
||
| // GetDeletes calculate the deletes that need to be send to the device. | ||
| func GetDeletes(e api.Entry, deletes types.DeleteEntriesList, aggregatePaths bool) (types.DeleteEntriesList, error) { |
There was a problem hiding this comment.
why do we accept the deletes list as an input here?
There was a problem hiding this comment.
It's ment to be a recursive function... To reduce allocation of DeleteEntriesList the result list is meant to be carried forward.
refactored with an internal function that takes that params list and the external call that inits an empty list.
| // if s is a presence container but has active childs, it should not be treated as a presence | ||
| // container, hence the leafvariants should not be processed. For presence container with | ||
| // childs the TypedValue.empty_val in the presence container is irrelevant. | ||
| if dt.entry.GetSchema().GetContainer().GetIsPresence() && len(dt.entry.GetChilds(types.DescendMethodActiveChilds)) > 0 { |
There was a problem hiding this comment.
refactor dt.entry.GetChilds() out to remove additional recomputation as it is also needed later on
There was a problem hiding this comment.
Aren't there also proto functions in other files too? Other duplicates should probably be removed
There was a problem hiding this comment.
No only the adapters that utilize these functions and adapt to the different interfaces
…centralize dispatch - extract entry validators into dedicated files (range, length, pattern, mandatory, min/max-elements) - keep validate package entrypoint focused on orchestration/result aggregation - introduce dedicated validator dispatch/registry file with shared ValidationFunc signature - precompute active validators once from config and pass through recursive processor tasks - simplify recursive validation path by executing only active validator functions per entry
e2324c9 to
eddffb1
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
Reorganizes the tree package by introducing a new
pkg/tree/apisurface and apkg/tree/constspackage, then updates the codebase to use those exported interfaces, types, and constants.pkg/tree/api) withEntry,LeafVariants, delete-path types, and non-revertive tracking; introducespkg/tree/opshelpers (e.g.,GetByOwner) and an ops interface.pkg/tree/constsand replaces many directtree.RunningIntentName/RunningValuesPrio/Replace*usages withconstsequivalents across datastore, targets, server, and tests.ShouldDelete,GetOrCreateChilds,ToJsonInternal),LeafVariantsaccessors, andTreeContextnow exposingSchemaClient,ExplicitDeletes, andNonRevertiveInfo.SdcpbPath.SdcpbPath()and updates callers, plus broad test updates to match new APIs and constants.